package com.ptszyxx.popose.module.base.user;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProviders;

import com.ptszyxx.popose.BR;
import com.ptszyxx.popose.R;
import com.ptszyxx.popose.databinding.ActivityUserBirthdayBinding;
import com.ptszyxx.popose.databinding.ActivityUserNickBinding;
import com.ptszyxx.popose.module.base.user.vm.UserBirthdayVM;
import com.ptszyxx.popose.module.base.user.vm.UserNickVM;
import com.ysg.base.BaseFragment;
import com.ysg.http.data.AppViewModelFactory;
import com.ysg.utils.YDialogUtil;

/**
 * 完善用户信息
 */
public class UserBirthdayFragment extends BaseFragment<ActivityUserBirthdayBinding, UserBirthdayVM> {

    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.activity_user_birthday;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public UserBirthdayVM initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getActivity().getApplication());
        return ViewModelProviders.of(this, factory).get(UserBirthdayVM.class);
    }

    @Override
    public void initViewObservable() {
        super.initViewObservable();
        viewModel.uc.onBirthDayEvent.observe(this, o -> showDialogBirthday());
    }

    private void showDialogBirthday() {
        YDialogUtil.getInstance().showDialogDate(getActivity(), s -> viewModel.birthday.set(s) );
    }
}